<?php

namespace App\Console\Commands;

use App\Services\Command\ModifyCommandService;
use Illuminate\Console\Command;

class ModifyCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:modify {type} {arg1?} {arg2?} {arg3?}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    public function handle(ModifyCommandService $service)
    {
        $fun = $this->argument('type');
        $arg = $this->arguments();
        unset($arg['command'], $arg['type']);
        $arg = collect($arg)->filter()->values()->all();
        if (method_exists($service, $fun)) {
            $service->$fun(...$arg);
        }
    }
}
